home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / pcc / v05n01 / dialr.bas < prev    next >
Encoding:
BASIC Source File  |  1991-12-16  |  3.5 KB  |  95 lines

  1. ' DIALER.BAS
  2. ' A program that searches a database file for a name you want
  3. ' and dials that person's telephone number for you. The program
  4. ' assumes the existence of a database file named CONTACTS.TXT
  5. ' in the current drive and directory and assumes that you have
  6. ' a Hayes-compatible modem attached to COM1.
  7.  
  8. DECLARE SUB DialNumber ()
  9. OPTION BASE 1
  10. DIM SHARED HomeAC$            ' Your local area code
  11. DIM SHARED Name$(4, 16)       ' Array to hold each name and phone number
  12. DIM SHARED NumNames%          ' Number of names found in database
  13. filename$ = "CONTACTS.TXT"    ' Name of contacts database file
  14. form$ = "\            \ \       \  (\ \)-\       \"
  15.  
  16. HomeAC$ = "415"     ' Your local area code; change when traveling
  17.  
  18. DO
  19.  
  20.     NumNames% = 0: search$ = "": hit% = 0
  21.     
  22.     OPEN filename$ FOR INPUT AS #1
  23.     CLS : LOCATE 3, 15: PRINT "SEARCH for a name in the database"
  24.     LOCATE 4, 15: PRINT "(To stop, enter END as the name)"
  25.     LOCATE 6, 15: INPUT "Enter name to search for:"; search$: PRINT
  26.     IF UCASE$(search$) = "END" THEN SYSTEM  ' Quit program and return to DOS
  27.  
  28.     DO WHILE (NOT EOF(1))
  29.         INPUT #1, last$, first$, area$, phone$
  30.         test$ = UCASE$(search$)
  31.         IF UCASE$(last$) = test$ OR UCASE$(first$) = test$ THEN
  32.             hit% = 1: NumNames% = NumNames% + 1
  33.             Name$(1, NumNames%) = last$: Name$(2, NumNames%) = first$
  34.             Name$(3, NumNames%) = area$: Name$(4, NumNames%) = phone$
  35.             IF NumNames% <= 9 THEN LOCATE , 15: PRINT NumNames%; "- ";
  36.             IF NumNames% > 9 THEN LOCATE , 14: PRINT NumNames%; "- ";
  37.             PRINT USING form$; last$; first$; area$; phone$
  38.         END IF
  39.     LOOP
  40.  
  41.     IF hit% <> 0 THEN
  42.         DialNumber
  43.     ELSE
  44.         LOCATE , 15: PRINT "No match found for "; search$
  45.         LOCATE , 15: PRINT "Press any key to continue"
  46.         DO WHILE INKEY$ = "": LOOP
  47.     END IF
  48.     
  49.     CLOSE #1
  50. LOOP
  51.  
  52. SUB DialNumber
  53.     LOCATE 3, 15: PRINT "Be sure your modem is turned on! "
  54.     LOCATE 4, 15: PRINT "You must pick up the handset by the second ring."
  55.     
  56.     DO
  57.         LOCATE 6, 65: PRINT "      ": LOCATE 6, 15
  58.         INPUT "Enter the number of the person you'd like to call: ", choice%
  59.     LOOP UNTIL choice% >= 1 AND choice% <= NumNames%
  60.     
  61.     PhoneNum$ = "": CLS : LOCATE 3, 15: PRINT "Dialing: ";
  62.     PRINT Name$(2, choice%); " "; Name$(1, choice%); "  ";
  63.     IF Name$(3, choice%) <> "" THEN
  64.         IF Name$(3, choice%) = HomeAC$ THEN
  65.             PhoneNum$ = ""
  66.         ELSE
  67.             PhoneNum$ = "1," + Name$(3, choice%)
  68.             PRINT "("; Name$(3, choice%); ")-";
  69.         END IF
  70.     END IF
  71.     PRINT Name$(4, choice%)
  72.     
  73. ' If some numbers in your home area code require
  74. ' that you first dial 1 before some numbers, remove
  75. ' the leading apostrophes from the following seven lines.
  76.    ' IF Name$(3, choice%) = HomeAC$ THEN
  77.       ' DO
  78.       ' LOCATE 5, 15
  79.       ' INPUT "Do you need to dial a 1 first (Y or N)"; One$
  80.       ' LOOP UNTIL UCASE$(One$) = "Y" OR UCASE$(One$) = "N"
  81.       ' IF UCASE$(One$) = "Y" THEN PhoneNum$ = "1,"
  82.     ' END IF
  83.     
  84.     PhoneNum$ = PhoneNum$ + Name$(4, choice%)
  85.     OPEN "COM1:1200,e,7,1,BIN,CD0,CS0,DS0,OP0" FOR RANDOM AS #2
  86.     PRINT #2, "ATS7=9DT", PhoneNum$
  87.     LOCATE 5, 15: PRINT "Pick up the phone before the second ring."
  88.     LOCATE 7, 15
  89.     PRINT "After picking up the phone, press any key to continue."
  90.     DO: LOOP UNTIL INKEY$ <> ""
  91.     PRINT #2, ATS7 = 30     ' Reset the value of S7 to maximum
  92.     CLOSE #2
  93.     
  94. END SUB
  95.